import 'package:flutter/material.dart';

class PopupWindow extends PopupRoute {
  final Widget child;
  final double? left;
  final double? top;

  PopupWindow({
    required this.child,
    this.left,
    this.top,
  });

  @override
  Duration get transitionDuration => const Duration(milliseconds: 100);

  @override
  String? get barrierLabel => null;

  @override
  Color? get barrierColor => null;

  @override
  bool get barrierDismissible => true;

  @override
  Widget buildPage(BuildContext context, Animation<double> animation,
      Animation<double> secondaryAnimation) {
    if (left == null || top == null) {
      return UnconstrainedBox(child: child);
    }
    return Stack(
      children: [
        Positioned(
          left: left,
          top: top,
          child: child,
        )
      ],
    );
  }
}
